package com.huadao.cart_ccs.modle;

import com.huadao.cart_ccs.base.BaseSerialPortModel;
import com.huadao.cart_ccs.common.ByteUtils;
import com.huadao.cart_ccs.data.bo.CO2BO;
import com.huadao.cart_ccs.data.bo.CommandWord;
import com.huadao.cart_ccs.data.bo.Protocol;

public class CO2Modle extends BaseSerialPortModel {
    private String TAG="CO2";

    public void readCO2(){
        Protocol params= ByteUtils.generateProtocol(CommandWord.read,new byte[]{CO2BO.ModularType_Atmosphere,CO2BO.Atmosphere_CO2,CO2BO.read},null);
        serialPortRequest(params);
    }

    public void setCO2(double CO2){
        byte[] CO2Bytes=ByteUtils.int2bytesLG(2, (int) (CO2*100));
        Protocol params= ByteUtils.generateProtocol(CommandWord.write,new byte[]{CO2BO.ModularType_Atmosphere,CO2BO.Atmosphere_CO2,CO2BO.write},CO2Bytes);
        serialPortRequest(params);
    }

    public void closeCO2() {
        Protocol params= ByteUtils.generateProtocol(CommandWord.write,new byte[]{CO2BO.ModularType_Atmosphere,CO2BO.Atmosphere_CO2,CO2BO.stop},null);
        serialPortRequest(params);
    }
}
